package com.sxhuayuan.parking.plugin.invoice;

import com.sxhuayuan.parking.service.PluginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 第三方开票系统调我们的接口获取信息
 * @author helong
 * @create 2019/8/29 17:20
 */
@Controller("invoicePlugin")
@RequestMapping("/plugin/invoice")
public class NoticeController {
	@Autowired
	PluginService pluginService;

	/** 第三方系统回调发票开具结果 */
	@PostMapping("/callback/{pluginId}")
	public void callback(HttpServletRequest request, HttpServletResponse response, @PathVariable String pluginId){
		InvoicePlugin invoicePlugin = pluginService.getInvoicePlugin(pluginId);
		if (invoicePlugin==null){
			return;
		}
		try {
			invoicePlugin.invoiceCallback(request,response);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
